<?php namespace Home\Controller; 
use Hdphp\Controller\Controller;

//前台控制器
class EnrollController extends Controller{
	protected $table="user";
	/**
	 * 注册
	 */
	public function reg(){
		if(IS_POST){
			$data =Db::table('user');
			//判断用户名是否已经注册过了
			foreach ($data as $v	) {
				if($_POST['username'] == $v['username']){
					success('用户名已存在');
				}
			}
			
			//追加一条
			$data[] = array(
				'username' => $_POST['username'],
				'password' => md5($_POST['password'])
			);
			//写入数据库
			dataToFile($data,'user');
			//成功提示
			success('注册成功');
		}
		
	}

}

